<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link href="../css/docs.css" type="text/css" rel="stylesheet" />
<link href="../css/prettify.css" type="text/css" rel="stylesheet" />
<script src="../js/prettify.js" type="text/javascript"></script>
</head>
<body onLoad="prettyPrint()">
<div class="g-unit" id="doc-content">
<div id="api-info-block">
    <div class="api-level">H3C CAS云管理平台</div>
  </div>
  <div id="jd-header">
    <h1>还原虚拟机</h1>
  </div>
</div>
<div id="jd-content">
<div class="jd-descr">
<p>从备份文件还原指定的虚拟机</p>
<h2><a name="uri"></a>接口 URI</h2>
<p>/cas/casrs/vm/restore</p>
<h2><a name="access"></a>访问方法</h2>
<dl>
  <dt><b>HTTP 方法</b></dt>
  <dd>PUT</dd>
  <dt><b>消息体</b></dt>
   <p>1.从主机本地目录还原</p>
  <div class="source">
  	<pre class="prettyprint lang-xml">&lt;vmRestoreParameter&gt;
    &lt;backupId&gt;10&lt;/backupId&gt;<br>    &lt;entryType&gt;VIRTUAL_HOST&lt;/entryType&gt;<br>    &lt;type&gt;cp&lt;/type&gt;<br>    &lt;directory&gt;/vms/images&lt;/directory&gt;<br>    &lt;vmName&gt;eq&lt;/vmName&gt;<br>    &lt;hostId&gt;72&lt;/hostId&gt;<br>    &lt;time&gt;2014-11-03 19:43:19&lt;/time&gt;<br>    &lt;rsDiskForRestore&gt;<br>        &lt;dataName&gt;/vms/images/ddd&lt;/dataName&gt;<br>        &lt;format&gt;qcow&lt;/format&gt;<br>        &lt;size&gt;6&lt;/size&gt;<br>        &lt;path&gt;/vms/images/ddd&lt;/path&gt;<br>    &lt;/rsDiskForRestore&gt;<br>    &lt;title&gt;qw&lt;/title&gt;<br>    &lt;isForce&gt;false&lt;/isForce&gt;<br>    &lt;tmpDir&gt;/vms/vmbackuptmp&lt;/tmpDir&gt;<br>&lt;/vmRestoreParameter&gt;</pre>
  </div>
  <p>2.从远端服务器还原</p>
  <div class="source">
  	<pre class="prettyprint lang-xml">&lt;vmRestoreParameter&gt;
    &lt;backupId&gt;10&lt;/backupId&gt;<br>    &lt;entryType&gt;VIRTUAL_HOST&lt;/entryType&gt;<br>    &lt;type&gt;scp&lt;/type&gt;<br>    &lt;directory&gt;/vms/images&lt;/directory&gt;<br>    &lt;targetAddr&gt;192.168.10.4&lt;/targetAddr&gt;<br>    &lt;userName&gt;root&lt;/userName&gt;<br>    &lt;password&gt;1q2w3e&lt;/password&gt;<br>    &lt;vmName&gt;eq&lt;/vmName&gt;<br>    &lt;hostId&gt;72&lt;/hostId&gt;<br>    &lt;time&gt;2014-11-03 19:44:55&lt;/time&gt;<br>    &lt;rsDiskForRestore&gt;<br>        &lt;dataName&gt;/vms/images/ddd&lt;/dataName&gt;<br>        &lt;format&gt;qcow&lt;/format&gt;<br>        &lt;size&gt;6&lt;/size&gt;<br>        &lt;path&gt;/vms/images/ddd&lt;/path&gt;<br>    &lt;/rsDiskForRestore&gt;<br>    &lt;title&gt;qw&lt;/title&gt;<br>    &lt;isForce&gt;false&lt;/isForce&gt;<br>    &lt;tmpDir&gt;/vms/vmbackuptmp&lt;/tmpDir&gt;<br>&lt;/vmRestoreParameter&gt;</pre>
  </div>
</dl>

<dt><a name="detail"></a><b>元素含义</b></dt>
  <table id="pubmethods" class="jd-sumtable">
    <tbody>
      <tr>
        <th colspan="2"><span class="prettyprint lang-xml">vmRestoreParameter</span>各子元素</th>
      </tr>
	        <tr>
        <td class="jd-typecol"><span class="prettyprint lang-xml">backupId</span></td>
        <td width="100%" class="jd-linkcol"><span class="sympad">备份记录ID。</span>
          <div class="jd-descrdiv">长整数（Long）类型。</div></td>
      </tr>
      <tr class="alt-color">
        <td class="jd-typecol"><span class="prettyprint lang-xml">entryType</span></td>
        <td width="100%" class="jd-linkcol"><span class="sympad">操作类型，此处必须为VIRTUAL_HOST。</span>
          <div class="jd-descrdiv">字符串（String）类型。</div></td>
      </tr>
	  <tr>
        <td class="jd-typecol"><span class="prettyprint lang-xml">type</span></td>
        <td class="jd-linkcol"><span class="sympad">恢复方式，cp：主机本地目录，scp：SSH/SCP方式，ftp：FTP方式。</span>
          <div class="jd-descrdiv">枚举(enum):cp，scp，ftp</div></td>
	  </tr>
	  <tr class="alt-color">
        <td class="jd-typecol"><span class="prettyprint lang-xml">directory</span></td>
        <td class="jd-linkcol"><span class="sympad">备份文件位置 。</span>
          <div class="jd-descrdiv">字符串（String）类型。</div></td>
	  </tr>
	  <tr>
        <td class="jd-typecol"><span class="prettyprint lang-xml">targetAddr</span></td>
        <td class="jd-linkcol"><span class="sympad">备份文件所在服务器IP地址</span>
          <DIV></DIV>
          <div class="jd-descrdiv">字符串（String）类型。</div></td>
	  </tr>
	  <tr class="alt-color">
        <td class="jd-typecol"><span class="prettyprint lang-xml">userName</span></td>
        <td class="jd-linkcol"><span class="sympad"> 备份文件所在服务器用户名</span>
          <div class="jd-descrdiv">字符串（String）类型。</div></td>
	  </tr>
	  <tr>
        <td class="jd-typecol"><span class="prettyprint lang-xml">password</span></td>
        <td class="jd-linkcol"><span class="sympad"></span><span class="sympad">备份文件所在服务器</span>器密码
          <div class="jd-descrdiv">字符串（String）类型。</div></td>
      </tr>
	  <tr class="alt-color">
        <td class="jd-typecol"><span class="prettyprint lang-xml">vmName</span></td>
        <td class="jd-linkcol">虚拟机名称
          <div class="jd-descrdiv">字符串（String）类型。</div></td>
	  </tr>
	  <tr>
        <td class="jd-typecol"><span class="prettyprint lang-xml">hostId</span></td>
        <td class="jd-linkcol"><span class="sympad"></span>主机ID
          <div class="jd-descrdiv">长整形(Long)类型。</div></td>
      </tr>
	  <tr>
        <td class="jd-typecol"><span class="prettyprint lang-xml">time</span></td>
        <td class="jd-linkcol"><span class="sympad"></span>备份文件时间
          <div class="jd-descrdiv">字符串（String）类型。</div></td>
      </tr>
	  <tr>
        <td class="jd-typecol"><span class="prettyprint lang-xml">hostId</span></td>
        <td class="jd-linkcol"><span class="sympad"></span>主机ID
          <div class="jd-descrdiv">长整形(Long)类型。</div></td>
      </tr>
	  <tr>
        <td class="jd-typecol"><span class="prettyprint lang-xml">title</span></td>
        <td class="jd-linkcol"><span class="sympad"></span>虚拟机显示名称。
          <div class="jd-descrdiv">字符串（String）类型。</div></td>
      </tr>
	  <tr>
        <td class="jd-typecol"><span class="prettyprint lang-xml">isForce</span></td>
        <td class="jd-linkcol"><span class="sympad"></span>虚拟机磁盘发生变化，是否强制还原。
          <div class="jd-descrdiv">枚举（enum类型。 true， fasle</div></td>
      </tr>
	  <tr>
        <td class="jd-typecol"><span class="prettyprint lang-xml">rsDiskForRestore</span></td>
        <td class="jd-linkcol"><span class="sympad"></span>磁盘信息
          <div class="jd-descrdiv">自定义类型。</div></td>
      </tr>
  </table>
  
  <table id="pubmethods" class="jd-sumtable">
    <tbody>
      <tr>
        <th colspan="2"><span class="prettyprint lang-xml">rsDiskForRestore</span>各子元素</th>
      </tr>
      <tr>
        <td class="jd-typecol"><span class="prettyprint lang-xml">dataName</span></td>
        <td width="100%" class="jd-linkcol"><span class="sympad">备份磁盘路径。</span>
          <div class="jd-descrdiv">字符串（String）类型。</div></td>
      </tr>
	  <tr>
        <td class="jd-typecol"><span class="prettyprint lang-xml">format</span></td>
        <td class="jd-linkcol"><span class="sympad">磁盘文件格式</span>。 qcow2或raw
            <div class="jd-descrdiv">字符串（String）类型。</div></td>
	  </tr>
	  <tr class="alt-color">
        <td class="jd-typecol"><span class="prettyprint lang-xml">size</span></td>
        <td class="jd-linkcol"><span class="sympad">备份文件大小 。</span>
          <div class="jd-descrdiv">整形(Integer)</div></td>
	  </tr>
	  <tr>
        <td class="jd-typecol"><span class="prettyprint lang-xml">path</span></td>
        <td class="jd-linkcol"><span class="sympad">磁盘还原路径。</span>
          <DIV></DIV>
          <div class="jd-descrdiv">字符串（String）类型。</div></td>
	  </tr>
  </table>
<h2><a name="result"></a>返回结果</h2>
<dl>
  <dt><b>状态码</b></dt>
  <dd>
  <ul>
    <li>200(OK)：提交删除任务成功。</li>
  </ul>
  <ul>
    <li>409(Conflict)：失败。</li>
  </ul>
  </dd>
  <dt><b>消息头</b></dt>
  <div class="source">
    <pre class="prettyprint lang-xml">HTTP/1.1 200 OK<br>Server: Apache-Coyote/1.1<br>Set-Cookie: JSESSIONID=BDF7B4EDFDBA9FBF003D195F802D705F; Path=/imcrs<br>Date: Fri, 23 Dec 2011 04:44:21 GMT
&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;yes&quot;?&gt;<br>&lt;taskMsg&gt;<br>	&lt;msgId&gt;1414980660458&lt;/msgId&gt;<br>	&lt;targetId&gt;331&lt;/targetId&gt;<br>	&lt;targetName&gt;qw&lt;/targetName&gt;<br>	&lt;completed&gt;false&lt;/completed&gt;<br>	&lt;progress&gt;0&lt;/progress&gt;<br>	&lt;eventType&gt;0&lt;/eventType&gt;<br>&lt;/taskMsg&gt;</pre>
  </div>
</dl>

    <h2><a name="example"></a>应用举例</h2>
    <p>还原主机id为72，虚拟机名称为eq的虚拟机，备份文件在远端服务器，方式为SSH/SCP。</p>
    <dl>
      <dt><b>请求</b></dt>
      <div class="source">
        <pre class="prettyprint lang-xml">PUT http://192.168.0.4:8080/cas/casrs/vm/restore
accept: application/xml
&lt;vmRestoreParameter&gt;
    &lt;backupId&gt;10&lt;/backupId&gt;<br>    &lt;entryType&gt;VIRTUAL_HOST&lt;/entryType&gt;<br>    &lt;type&gt;scp&lt;/type&gt;<br>    &lt;directory&gt;/vms/images&lt;/directory&gt;<br>    &lt;targetAddr&gt;192.168.10.4&lt;/targetAddr&gt;<br>    &lt;userName&gt;root&lt;/userName&gt;<br>    &lt;password&gt;1q2w3e&lt;/password&gt;<br>    &lt;vmName&gt;eq&lt;/vmName&gt;<br>    &lt;hostId&gt;72&lt;/hostId&gt;<br>    &lt;time&gt;2014-11-03 19:44:55&lt;/time&gt;<br>    &lt;rsDiskForRestore&gt;<br>        &lt;dataName&gt;/vms/images/ddd&lt;/dataName&gt;<br>        &lt;format&gt;qcow&lt;/format&gt;<br>        &lt;size&gt;6&lt;/size&gt;<br>        &lt;path&gt;/vms/images/ddd&lt;/path&gt;<br>    &lt;/rsDiskForRestore&gt;<br>    &lt;title&gt;qw&lt;/title&gt;<br>    &lt;isForce&gt;false&lt;/isForce&gt;<br>    &lt;tmpDir&gt;/vms/vmbackuptmp&lt;/tmpDir&gt;<br>&lt;/vmRestoreParameter&gt;
</pre>
      </div>
      <dt><b>回应</b></dt>
      <div class="source"><pre class="prettyprint lang-xml">HTTP/1.1 200 OK<br>Server: Apache-Coyote/1.1<br>Set-Cookie: JSESSIONID=BDF7B4EDFDBA9FBF003D195F802D705F; Path=/imcrs<br>Date: Fri, 23 Dec 2011 04:44:21 GMT
&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;yes&quot;?&gt;<br>&lt;taskMsg&gt;<br>	&lt;msgId&gt;1414980660458&lt;/msgId&gt;<br>	&lt;targetId&gt;331&lt;/targetId&gt;<br>	&lt;targetName&gt;qw&lt;/targetName&gt;<br>	&lt;completed&gt;false&lt;/completed&gt;<br>	&lt;progress&gt;0&lt;/progress&gt;<br>	&lt;eventType&gt;0&lt;/eventType&gt;<br>&lt;/taskMsg&gt;</pre>
      </div>
    </dl>
    
</div>
</div>
</div>
</body>
</html>